<script type="text/javascript" src="{$base_uri}js/AJAX_Insurance.js"></script>
<script type="text/javascript">
{literal}
    $(document).ready(function(){
        $('#registeredHospital').autocomplete('../Insurance/getHospitalAjax?set_ajax_view',
                {                    
                    matchContains: true,
                    autoFill: false,
                    cacheLength: 5,
                    formatItem: function(data, i, total) {      
                        return data[1];
                    }
                }
        );

        $("#registeredHospital").result(function(event, data, formatted) {
        	$(this).val(data[1]);        	  
            $('#registeredHospitalId').val(data[0]);                                        
        });  
        
        $('#insuranceCode_0').autotab({ target: $('#insuranceCode_1'), format: 'text', uppercase: true});
        $('#insuranceCode_1').autotab({privious: $('#insuranceCode_0'), target: $('#insuranceCode_2'), format: 'numeric', uppercase: true});
        $('#insuranceCode_2').autotab({privious: $('#insuranceCode_1'), target: $('#insuranceCode_3'), format: 'numeric', uppercase: true});
        $('#insuranceCode_3').autotab({privious: $('#insuranceCode_2'), target: $('#insuranceCode_4'), format: 'numeric', uppercase: true});
        $('#insuranceCode_4').autotab({privious: $('#insuranceCode_3'), target: $('#insuranceCode_5'), format: 'numeric', uppercase: true});
        $('#insuranceCode_5').autotab({privious: $('#insuranceCode_4'), target: $('#issued_' + {/literal}'{$datePart_0}'{literal}), format: 'numeric', uppercase: true});

        $('#issued_' + {/literal}'{$datePart_0}'{literal}).autotab({privious: $('#insuranceCode_5'), target: $('#issued_' + {/literal}'{$datePart_1}'{literal}), format: 'numeric'});
        $('#issued_' + {/literal}'{$datePart_1}'{literal}).autotab({privious: $('#issued_' + {/literal}'{$datePart_2}'{literal}), target: $('#issued_' + {/literal}'{$datePart_2}'{literal}), format: 'numeric'});
        $('#issued_' + {/literal}'{$datePart_2}'{literal}).autotab({privious: $('#issued_' + {/literal}'{$datePart_1}'{literal}), target: $('#expired_' + {/literal}'{$datePart_0}'{literal}), format: 'numeric'});

        $('#expired_' + {/literal}'{$datePart_0}'{literal}).autotab({privious: $('#issued_' + {/literal}'{$datePart_2}'{literal}), target: $('#expired_' + {/literal}'{$datePart_1}'{literal}), format: 'numeric'});
        $('#expired_' + {/literal}'{$datePart_1}'{literal}).autotab({privious: $('#expired_' + {/literal}'{$datePart_2}'{literal}), target: $('#expired_' + {/literal}'{$datePart_2}'{literal}), format: 'numeric'});
        $('#expired_' + {/literal}'{$datePart_2}'{literal}).autotab({privious: $('#expired_' + {/literal}'{$datePart_1}'{literal}), target: $('#registeredHospital'), format: 'numeric'});
        
    });
{/literal}
</script>

<div style='margin-top: 5px; border: 1px solid #BBB; padding: 0px 0px; -moz-box-shadow:0 0 3px #AAA; -webkit-box-shadow:0 0 3px #AAA;'>        
    <span style="font-style: italic;" id="addInsuranceMsg" class="formAlertMsg"></span>    
    <form id="addInsuranceForm">
        <input type="hidden" name="patientId" id="patientId" value="{$patientId}">                          
        <div class="field-row add-patient-row">
            <div class="field-label add-patient-label" style="width: 120px;">{translate}Health insurance No.{/translate}</div>
            <div class="field-value add-patient-value" style="width: 270px;">
                <input type="text" style="width: 25px;" id="insuranceCode_0" name="insuranceCode_0" maxlength="2" value="{$insuranceCode.0}">
                <input type="text" style="width: 25px;" id="insuranceCode_1" name="insuranceCode_1" maxlength="1" value="{$insuranceCode.1}">
                <input type="text" style="width: 25px;" id="insuranceCode_2" name="insuranceCode_2" maxlength="2" value="{$insuranceCode.2}">
                <input type="text" style="width: 25px;" id="insuranceCode_3" name="insuranceCode_3" maxlength="2" value="{$insuranceCode.3}">
                <input type="text" style="width: 40px;" id="insuranceCode_4" name="insuranceCode_4" maxlength="3" value="{$insuranceCode.4}">
                <input type="text" style="width: 50px;" id="insuranceCode_5" name="insuranceCode_5" maxlength="5" value="{$insuranceCode.5}">
            </div>
            
            <div class="field-label add-patient-label" style="width: 120px;">{translate}Usage time{/translate}</div>
            <div class="field-value add-patient-value" id="usageTimeContainer">
                <input type="text" name="issued_{$datePart_0}" id="issued_{$datePart_0}" style="width: 25px;" maxlength="2" value="{$date_issued.0}"> 
                <input type="text" name="issued_{$datePart_1}" id="issued_{$datePart_1}" style="width: 25px;" maxlength="2" value="{$date_issued.1}">
                <input type="text" name="issued_{$datePart_2}" id="issued_{$datePart_2}" style="width: 40px;" maxlength="4" value="{$date_issued.2}">
                <span class="label"> - </span>
                <input type="text" name="expired_{$datePart_0}" id="expired_{$datePart_0}" style="width: 25px;" maxlength="2" value="{$date_expired.0}"> 
                <input type="text" name="expired_{$datePart_1}" id="expired_{$datePart_1}" style="width: 25px;" maxlength="2" value="{$date_expired.1}">
                <input type="text" name="expired_{$datePart_2}" id="expired_{$datePart_2}" style="width: 40px;" maxlength="4" value="{$date_expired.2}">
                <span class="label" style="width: 21px; color: #AAA;">({$datePart_0}-{$datePart_1}-{$datePart_2})</span>
            </div>  
            <div style="clear: both;"></div>
        </div>                
        
        <div class="field-row add-patient-row">
            <div class="field-label add-patient-label" style="width: 120px;">{translate}Registered hospital{/translate}</div>
            
            <div class="field-value add-patient-value" style="width: 270px;">                
                <input type="text" name="registeredHospital"  id="registeredHospital" style="width: 245px;" value="{$hospitalName}" onkeyup="return moveNext(event, this.id, null)">
                <input type="hidden" name="registeredHospitalId" id="registeredHospitalId" value="{$registeredHospitalId}">
                &nbsp;                  
            </div>  
            
            <div class="field-label add-patient-label" style="width: 120px;">&nbsp;</div>
            <div class="field-value add-patient-value" style="width: 120px;">
                <input name="correctRoute" type="checkbox" {if ($correctRoute eq 1 or $insuranceId eq 0)} checked="checked" {/if}> <span style="font-weight: bold; color: #3B87C5;">{translate}Correct route{/translate}</span>                
            </div>                        
                         
            <div class="field-value add-patient-value" style="width: 200px;">
                <input name="paidFor36Month" type="checkbox" {if $paidFor36Month  eq 1} checked="checked" {/if}> <span style="font-weight: bold; color: #3B87C5;">{translate}Lien tuc 36 thang{/translate}</span>
            </div>
            <div style="clear: both;"></div>
        </div>
        
         
    </form>
</div>